package com.example.teamtribe.main.seek;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

public class SeekPagerAdapter extends FragmentPagerAdapter {

    private ClubFragment fragClub;
    private PersonFragment fragPerson;
    private GroupFragment fragGroup;
    private String[] titles = new String[] {"社团", "个人", "群聊"};

    public SeekPagerAdapter(FragmentManager fm) {
        super(fm);
        fragClub = new ClubFragment();
        fragPerson = new PersonFragment();
        fragGroup = new GroupFragment();
    }

    @Override
    public Fragment getItem(int position) {
        switch (position) {
            case 0:
                return fragClub;
            case 1:
                return fragPerson;
            case 2:
                return fragGroup;
            default:
                return fragClub;
        }
    }

    @Override
    public int getCount() {
        return titles.length;
    }

    @Override
    public int getItemPosition(Object object) {
        if (object instanceof ClubFragment) {
            return 0;
        } else if (object instanceof PersonFragment) {
            return 1;
        } else {
            return 2;
        }
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
